# cmake_minimum_required(VERSION 3.10)
# project(DoseStatistics)

#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx dose_statistics lib
set(MY_LIB dosestat)

add_library(${MY_LIB} SHARED)
#--- 使用自定义函数配置导出头文件
my_config_export_header(${MY_LIB} ${MY_EXPORTS_DIR})

target_sources(${MY_LIB}
    PRIVATE
        DoseStat.cpp
    PUBLIC
        DoseStat.h
)
# 添加头文件搜索路径
target_include_directories(${MY_LIB}
    PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
)
# 链接依赖库
target_link_libraries(${MY_LIB}
    PUBLIC
        common
)
install(TARGETS ${MY_LIB}
    RUNTIME DESTINATION bin
    LIBRARY DESTINATION bin
    ARCHIVE DESTINATION bin
)

##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 添加 test dose stat lib
set(MY_LIB_TE testdosestat)
include(00testdosestat.cmake)

##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 添加Python绑定模块
set(MY_PY_BIND dosestatpy)
include(01pybind11.cmake)

##============================= 为Visual Studio生成文件夹结构（如果适用）
if(MSVC)
    set_property(GLOBAL PROPERTY USE_FOLDERS ON)
    set_target_properties(${MY_LIB} PROPERTIES FOLDER "dosestat")
    set_target_properties(${MY_LIB_TE} PROPERTIES FOLDER "dosestat")
    set_target_properties(${MY_PY_BIND} PROPERTIES FOLDER "dosestat")
endif()

##============================= 添加编译选项以提高代码质量
if(FALSE AND MSVC)
    target_compile_options(${MY_LIB} PRIVATE /W4 /WX)
endif()
if(LINUX)
    # target_compile_options(${MY_LIB} PRIVATE -Wall -Wextra -Wpedantic -Werror)
    target_compile_options(${MY_LIB} PRIVATE -Wall -Wextra -Wpedantic)
endif()

##============================= 拷贝 .npz 文件到二进制输出目录
if(FALSE)
    set(TEST_IO_DIR "${MY_ROOT_DIR}/testio")
    file(GLOB NPZ_FILES "${TEST_IO_DIR}/*.npz")
    if(NPZ_FILES)
        add_custom_command(
            TARGET ${MY_LIB}
            POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E make_directory "${MY_PATH_BIN}"
            COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NPZ_FILES} "${MY_PATH_BIN}"
            COMMENT "Copying .npz files from ${TEST_IO_DIR} to ${MY_PATH_BIN}"
        )
    elseif(FALSE)
        message(WARNING "No .npz files found in ${TEST_IO_DIR}")
    endif()
endif()


